package com.tdkj.action.backstage.shop;

import java.math.BigDecimal;
import java.util.List;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.shop.BeanShelfCustom;
import com.tdkj.model.shop.BeanShelfDefault;
import com.tdkj.service.shop.IBeanShelfCustomService;
import com.tdkj.service.shop.IBeanShelfDefaultService;


public class ShelfCustomAction extends BaseAction {
    
	private IBeanShelfCustomService shelfCustomService;
	
	private IBeanShelfDefaultService shelfDefaultService;
	
	
	private Long id;
	private Integer quantity;
	private BigDecimal price;
	private String unit;
	
	private BeanShelfDefault shelfDefault ;
	
	private BeanShelfCustom shelfCustom ;
	
	private List<BeanShelfCustom> shelfCustoms ;
	
	public String add() {
		shelfCustomService.add(quantity, unit, price);
		return execute();
	}
	
	public String edit() {
		shelfCustom = shelfCustomService.findById(id, BeanShelfCustom.class);
		return "edit";
	}
	
	public String update() {
		shelfCustomService.update(id, quantity, unit, price);
		return edit();
	}

	public String del() {
		shelfCustomService.delete(id, BeanShelfCustom.class);
		return execute();
	}
	
	public String execute() {
		shelfDefault = shelfDefaultService.getShelfDefault();
		shelfCustoms = shelfCustomService.findAll(BeanShelfCustom.class);
		return "success";
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the quantity
	 */
	public Integer getQuantity() {
		return quantity;
	}

	/**
	 * @param quantity the quantity to set
	 */
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	/**
	 * @return the price
	 */
	public BigDecimal getPrice() {
		return price;
	}

	/**
	 * @param price the price to set
	 */
	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	/**
	 * @return the unit
	 */
	public String getUnit() {
		return unit;
	}

	/**
	 * @param unit the unit to set
	 */
	public void setUnit(String unit) {
		this.unit = unit;
	}

	/**
	 * @return the shelfCustom
	 */
	public BeanShelfCustom getShelfCustom() {
		return shelfCustom;
	}

	/**
	 * @param shelfCustom the shelfCustom to set
	 */
	public void setShelfCustom(BeanShelfCustom shelfCustom) {
		this.shelfCustom = shelfCustom;
	}

	/**
	 * @return the shelfCustoms
	 */
	public List<BeanShelfCustom> getShelfCustoms() {
		return shelfCustoms;
	}

	/**
	 * @param shelfCustoms the shelfCustoms to set
	 */
	public void setShelfCustoms(List<BeanShelfCustom> shelfCustoms) {
		this.shelfCustoms = shelfCustoms;
	}

	/**
	 * @param shelfCustomService the shelfCustomService to set
	 */
	@Resource
	public void setShelfCustomService(IBeanShelfCustomService shelfCustomService) {
		this.shelfCustomService = shelfCustomService;
	}

	/**
	 * @return the shelfDefault
	 */
	public BeanShelfDefault getShelfDefault() {
		return shelfDefault;
	}

	/**
	 * @param shelfDefault the shelfDefault to set
	 */
	public void setShelfDefault(BeanShelfDefault shelfDefault) {
		this.shelfDefault = shelfDefault;
	}

	/**
	 * @param shelfDefaultService the shelfDefaultService to set
	 */
	@Resource
	public void setShelfDefaultService(IBeanShelfDefaultService shelfDefaultService) {
		this.shelfDefaultService = shelfDefaultService;
	}

}
